﻿#include "../HExitPanel.h"
#include "../../include/StdAfx.h"
#include "../../include/HGlobalVariable.h"

//HExitPanel *HExitPanel::m_pSelf = new HExitPanel(NULL);

HExitPanel::HExitPanel(QWidget *parent)
    :HMoveableWidget(parent)
{

	setWindowFlags(Qt::FramelessWindowHint | Qt::Window);
	setWindowModality(Qt::ApplicationModal);
	setFixedSize(304,159);

    initUI();
	initStyle();
}

HExitPanel::~HExitPanel()
{

}

//HExitPanel *HExitPanel::instance()
//{
//    return m_pSelf;
//}

void HExitPanel::paintEvent(QPaintEvent *event)
{
	QStyleOption opt;
	opt.init(this);
	QPainter p(this);
	style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
	QWidget::paintEvent(event);
}

void HExitPanel::initUI()
{
    m_plblText = new QLabel();
    m_plblText->setAlignment(Qt::AlignCenter);
	m_plblText->setText(QString::fromLocal8Bit("确定退出本系统吗？"));
	m_plblText->setObjectName("login_setting_lbl");

    m_ppbOK = new QPushButton(this);
    m_ppbOK->setText(QString::fromLocal8Bit("确定"));
    m_ppbOK->setObjectName("setting_btn_cancel");
	m_ppbOK->setFixedSize(NSAVEBTNWIDTH,NSAVEBTNHEIGHT);

    m_ppbCancel = new QPushButton(this);
    m_ppbCancel->setText(QString::fromLocal8Bit("取消"));
    m_ppbCancel->setObjectName("setting_btn_cancel");
	m_ppbCancel->setFixedSize(NSAVEBTNWIDTH,NSAVEBTNHEIGHT);

    m_phblFunction = new QHBoxLayout();
    m_phblFunction->setSpacing(20);
    m_phblFunction->setContentsMargins(0,0,0,0);

    m_pvblMain = new QVBoxLayout();
    m_pvblMain->setContentsMargins(20,20,20,20);

    m_phblFunction->addWidget(m_ppbOK);
    m_phblFunction->addWidget(m_ppbCancel);

    m_pvblMain->addWidget(m_plblText,2);
    m_pvblMain->addLayout(m_phblFunction,1);

    this->setLayout(m_pvblMain);

    connect(m_ppbOK,SIGNAL(clicked()),qApp,SLOT(quit()));
    connect(m_ppbCancel,SIGNAL(clicked()),this,SLOT(close()));
}

void HExitPanel::initStyle()
{
	setObjectName("dc_wnd_popScreenSelect");
	QFile file(g_strAppPath + QSSRELATIONPATH + "HLoginPanel.qss");
	QFile file1(g_strAppPath + QSSRELATIONPATH + "HDomeControlPanel.qss");
	if(file.open(QIODevice::ReadOnly) && file1.open(QIODevice::ReadOnly))
	{
		QString strStyle = file.readAll();
		strStyle.append(file1.readAll());

		setStyleSheet(strStyle.arg(g_strAppPath + g_strImageRelationPath));

		file.close();
		file1.close();
	}

}
